package com.summer.obj;

public class ConstructionTest {

	
	public static void main(String[] args) {
//		Test test = new Test("sanmao");
		TestSub test1 = new TestSub("sanmao");
		TestSub test2 = new TestSub("sanmao");
		test1.println();
		
		Class<Test> cls = Test.class;
		
		System.out.println("======" + (test1.getClass().equals(test2.getClass())));
		System.out.println("======" + (test1.getClass() == test2.getClass()));
		System.out.println("======" + (test1.getClass().equals(TestSub.class)));
		System.out.println("======" + (test1.getClass().equals(Test.class)));
		
		System.out.println("======" + (cls.equals(Test.class)));
		System.out.println("======" + (cls.equals(TestSub.class)));
		
	}
	
	public static class TestSub extends Test {

		public final Var var3 = new Var(getName());
		
		public TestSub(String name) {
			this(name, 0);
		}

		public TestSub(String name, int index) {
			super(name, index);
		}
		
		
		public void println() {
			super.println();
			System.out.println(var3.var);
		}
	}
	
	public static class Test {

		public String name;
		public final Var var1 = new Var(name);
		public final Var var2 = new Var(getName());
		
		public Test(String name) {
			this(name, 0);
		}
		
		public Test(String name,int index) {
			this.name = name;
		}
		
		public String getName() {
			return name;
		}
		
		public void println() {
			System.out.println(var1.var);
			System.out.println(var2.var);
		}
		
	}
	
	public static class Var {
		String var;
		public Var(String var) {
			this.var = var;
		}
	}
	
	
}
